using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;
using Utility;

namespace BUS
{
   public class tbBinhluanBUS
   {
       public static void Insert(tbBinhluan bl)
       {
           tbBinhluanDAL blDAL = new tbBinhluanDAL();
           blDAL.Insert(bl);
       }
       public static void Update(tbBinhluan bl)
       {
           tbBinhluanDAL blDAL = new tbBinhluanDAL();
           blDAL.Update(bl);
       }
       public static void Delete(int iD)
       {
           tbBinhluanDAL blDAL = new tbBinhluanDAL();
           blDAL.Delete(iD);
       }
       public static tbBinhluanCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
       {
           tbBinhluanDAL blDAL = new tbBinhluanDAL();
           return blDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
       }
       public static tbBinhluanCollection GetAll()
       {
           int total = 0;
           Criteria cri = new Criteria();
           tbBinhluanDAL blDAL = new tbBinhluanDAL();
           return blDAL.Get(cri.Criter, 0, 0, tbBinhluanCollumn.Mabl.ToString(), OrderDirection.ASC.ToString(), out total);
       }
       public static tbBinhluan GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbBinhluanCollumn.Mabl.ToString(), Condition.EQUAL, iD);
           tbBinhluanDAL blDAL = new tbBinhluanDAL();
           tbBinhluanCollection blCollection = blDAL.Get(cri.Criter, 0, 0, tbBinhluanCollumn.Mabl.ToString(), OrderDirection.ASC.ToString(), out total);
           if (blCollection.Count > 0)
               return blCollection[0];
           return null;
       }
       public static tbBinhluanCollection GetLimited(int number)
       {
           int total = 0;
           Criteria cri = new Criteria();
           tbBinhluanDAL blDAL = new tbBinhluanDAL();
           return blDAL.Get(cri.Criter, 1, number,
            tbBinhluanCollumn.Mabl.ToString(), OrderDirection.DESC.ToString(), out total);
       }
       public static tbBinhluanCollection GetPromotion(int number)
       {
           int total = 0;
           Criteria cri = new Criteria();
           tbBinhluanDAL blDAL = new tbBinhluanDAL();
           return blDAL.Get(cri.Criter, 1, number,
              tbBinhluanCollumn.Mabl.ToString(), OrderDirection.DESC.ToString(), out total);
       }
   }
}
